<?php
echo $this->Html->script('jquery.ui.core.min');
echo $this->Html->script('jquery.validate.min');
echo $this->Html->script('jquery.ui.datepicker.min');
echo $this->Html->css('jquery-ui');
?>
<script type="text/javascript">
    $(document).ready(function(){
        $("form").validate({
            errorClass: "jqueryError",
            errorElement: 'label',
            debug: false,
            submitHandler: function(form) {
                $(':submit', form).attr('disabled', 'disabled').addClass('inactive');
                form.submit();
            }
        });
    });

    $(function(){
        $('#ActivityNextfollowupdate').datepicker({
            defaultDate: new Date(),
            changeMonth: true,
            minDate: '0D',
            changeYear: true,
            dateFormat: 'dd-mm-yy',
            showOn: 'both',
            buttonImage: '<?php echo APP_URL; ?>img/calendar.png',
            buttonImageOnly: true
        });
    })
</script>
<div class="email form">
    <?php
    echo $this->Form->create('Potentialactivity', array(
        'url' => array(
            'controller' => 'potentialactivities',
            'action' => 'email'
        )
    )
    );
    ?>
    <fieldset>
        <legend><?php __('Send an email'); ?></legend>
        <?php
        echo $this->Form->input('Potentialactivity.potential_id', array(
            'type' => 'hidden',
            'value' => $potentialinfo['Potential']['id']
        ));

        echo "<h1>" . $this->Html->tag('label', 'To, "'.$potentialinfo['User']['firstname'] . "&nbsp;" . $potentialinfo['User']['lastname']. '"&nbsp;' . '&lt;' . $potentialinfo['User']['email1'] . '&gt;') . "</h1>";

        echo $this->Form->input('Potentialactivity.subject', array(
            'label' => 'Subject',
            'class' => 'required',
            'between' => $this->Html->tag('span', '(Enter the subject for email)', array('class' => 'description'))
        ));

        echo $this->Form->input('Document', array(
            'type' => 'select',
            'options' => $documents,
            'multiple' => true,
            'label' => 'Documents',
            'class' => 'required',
            'between' => $this->Html->tag('span', '(Select the documents for attachment to this form)', array('class' => 'description'))
        ));

        echo $this->Form->input('Potentialactivity.description', array(
            'type' => 'textarea',
            'label' => 'Body',
            'between' => $this->Html->tag('span', '(Enter the email content)', array('class' => 'description'))
        ));

        echo $this->Form->input('Potentialactivity.nextfollowupdate', array(
            'id' => 'ActivityNextfollowupdate',
            'type' => 'text',
            'readonly' => true,
            'label' => 'Next Followup Date',
            'between' => $this->Html->tag('span', '(Choose the next followup date)', array('class' => 'description'))
        ));

        echo $this->Form->input('Potentialactivity.employee_id', array(
            'type' => 'hidden',
            'value' => $this->Session->read('Auth.Employee.id')
        ));

        echo $this->Form->input('Potentialactivity.assignedtoemployee_id', array(
            'type' => 'hidden',
            'value' => $this->Session->read('Auth.Employee.id')
        ));

        echo $this->Form->input('Potentialactivity.activitytype_id', array(
            'type' => 'hidden',
            'value' => Configure::read('activitytype.email.id')
        ));
        ?>
    </fieldset>
    <?php echo $this->Form->end(__('Send', true)); ?>
</div>